<template>
	<view class="schedule-box">
		<title title="学习进度" :showLine='true' :lineShow='true'></title>
		<studyList :list='list' @handStudy='handStudy'></studyList>
	</view>
</template>

<script>
	import title from '@/components/bs-title/bs-title.vue'
	import studyList from '@/components/bs-study-list/bs-study-list.vue'
	export default {
		components: {
			title,
			studyList
		},
		props: {
			list: {
				type: Array,
				default: () => []
			},
			course: {
				type: Object,
				default: () => {}
			}
		},
		data() {
			return {

			};
		},
		methods: {
			handStudy(item) {
				switch (item.status) {
					case 1: //解锁课程
						uni.showModal({
							confirmText: '确定解锁',
							content: '是否解锁',
							title: '解锁课程',
							success: async (res) => {
								if (res.confirm) {
									let res = await this.$u.api.unlockCourseProgress({
										courseId: this.course.courseId,
									});
									uni.showToast({
										title: '解锁成功',
										incon: 'none'
									})
									await this.$parent.getStudyPlan()
									console.log(res)
								}
							}
						})

						break
					case 2: //立即学习
						uni.navigateTo({
							url: `/pages/onlineTrain/trainDetails/studyVideo/studyVideo?courseId=${this.course.courseId}&classId=${item.classId}&courseIntroduction=${this.course.courseIntroduction}`
						})
						break
					case 3://学习完成,重复观看
						uni.navigateTo({
							url: `/pages/onlineTrain/trainDetails/studyVideo/studyVideo?courseId=${this.course.courseId}&classId=${item.classId}&courseIntroduction=${this.course.courseIntroduction}`
						})
						break
					default:
						break
				}

			}

		}
	}
</script>

<style lang="scss" scoped>
	.schedule-box {
		margin-bottom: 80rpx;
	}
</style>
